package com.lwq.orderservice.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;

import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @Auther: 陆
 * @Date: 2024/01/31/8:35
 * @Description:
 */

@Configuration
@LoadBalancerClient(value = "user-service",configuration = LoadBalancerConfig.class)
// user-service: 指定要执行负载均衡的服务，LoadBalancerConfig.class: 执行负载均衡的算法实现
public class BeanConfiguration {
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

}
